package com.hsxc.cdz.monitor.bean.extend.pile.content;

import org.jdom2.IllegalDataException;

import com.hsxc.cdz.base.util.BytesUtil;

public class BillPileContent extends PileContent {

	/**************************************************/
	//对象私有属性
	private String startTime;  //充电开始时间
	private String endTime;    //充电结束时间
	private String cardNum;    //用户卡号
	private int startRecord;   //充电前电表读数
	private int endRecord;     //充电后电表读数
	private int electricity;   //充电电量
	private int sumMoney;         //充电费用
	private int startCardMon;  //充电开始前卡上余额 
	private int endCardMon;    //充电后卡上余额
	private int serviceMon;   //服务费金额 
	private int isPay;         //是否支付  1 已支付 0 未支付
	
	//协议转换长度
	private static final int STARTTIME_LENGTH = 7;   //充电开始时间长度
	private static final int ENDTIME_LENGTH = 7;     //充电结束时间长度
	private static final int CARDNUM_LENGTH = 10;    //用户卡号长度
	private static final int STARTRECORD_LENGTH = 4; //充电前电表读书长度
	private static final int ENDRECORD_LENGTH = 4;   //充电后电表读书长度
	private static final int ELECTRICITY_LENGTH = 4; //充电电量长度
	private static final int SUMMONEY_LENGTH = 4;    //充电金额长度
	private static final int STARTCARDMON_LENGTH = 4;//充点前卡上余额
	private static final int ENDCARDMON_LENGTH = 4;  //充电后卡上余额 
	private static final int SERVICEMON_LENGTH = 2;  //服务费金额
	private static final int ISPAY_LENGTH = 1;       //是否支付长度
	
	public static final int length = 51;             //报文长度
	
	/********************************************************/
	public BillPileContent(){
	}
	public BillPileContent(byte[] data) throws Exception{
		this();
		this.getContent(data);
		
	}
	
	/********************************************************/
	//重写父类方法
	@Override
	public void getContent(byte[] data) {
		
		if(data==null||data.length!=length){
			throw new IllegalDataException("报文体byte[]数据长度错误");
		}
		
		byte[] temp;
	    int templength = 0;   
        temp = BytesUtil.getByte(templength,STARTTIME_LENGTH,data);
        this.setStartTime(BytesUtil.bcdBytesToStr(temp));
        templength += STARTTIME_LENGTH;
        
        temp = BytesUtil.getByte(templength,ENDTIME_LENGTH,data);
        this.setEndTime(BytesUtil.bcdBytesToStr(temp));
        templength += ENDTIME_LENGTH;
        
        temp = BytesUtil.getByte(templength,CARDNUM_LENGTH,data);
        this.setCardNum(BytesUtil.bcdBytesToStr(temp));
        templength += CARDNUM_LENGTH;
        
        temp = BytesUtil.getByte(templength,STARTRECORD_LENGTH,data);
        this.setStartRecord(BytesUtil.bytesToIntDesc(temp));
        templength += STARTRECORD_LENGTH;
        
        temp = BytesUtil.getByte(templength,ENDRECORD_LENGTH,data);
        this.setEndRecord(BytesUtil.bytesToIntDesc(temp));
        templength += ENDRECORD_LENGTH;
        
        temp = BytesUtil.getByte(templength,ELECTRICITY_LENGTH,data);
        this.setElectricity(BytesUtil.bytesToIntDesc(temp));
        templength += ELECTRICITY_LENGTH;
        
        temp = BytesUtil.getByte(templength,SUMMONEY_LENGTH,data);
        this.setSumMoney(BytesUtil.bytesToIntDesc(temp));
        templength += SUMMONEY_LENGTH;
        
        temp = BytesUtil.getByte(templength,STARTCARDMON_LENGTH,data);
        this.setStartCardMon(BytesUtil.bytesToIntDesc(temp));
        templength += STARTCARDMON_LENGTH;
        
        temp = BytesUtil.getByte(templength,ENDCARDMON_LENGTH,data);
        this.setEndCardMon(BytesUtil.bytesToIntDesc(temp));
        templength += ENDCARDMON_LENGTH;
        
        temp = BytesUtil.getByte(templength,SERVICEMON_LENGTH,data);
        this.setServiceMon(BytesUtil.bytesToIntDesc(temp));
        templength += SERVICEMON_LENGTH;
        
        temp = BytesUtil.getByte(templength,ISPAY_LENGTH,data);
        this.setIsPay(BytesUtil.bytesToIntSeq(temp));
	}
	
	/*******************************************************/
	//get() and set()
	public String getStartTime() {
		return startTime;
	}
	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}
	public String getEndTime() {
		return endTime;
	}
	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}
	public String getCardNum() {
		return cardNum;
	}
	public void setCardNum(String cardNum) {
		this.cardNum = cardNum;
	}
	public int getStartRecord() {
		return startRecord;
	}
	public void setStartRecord(int startRecord) {
		this.startRecord = startRecord;
	}
	public int getEndRecord() {
		return endRecord;
	}
	public void setEndRecord(int endRecord) {
		this.endRecord = endRecord;
	}
	public int getElectricity() {
		return electricity;
	}
	public void setElectricity(int electricity) {
		this.electricity = electricity;
	}
	public int getSumMoney() {
		return sumMoney;
	}
	public void setSumMoney(int sumMoney) {
		this.sumMoney = sumMoney;
	}
	public int getStartCardMon() {
		return startCardMon;
	}
	public void setStartCardMon(int startCardMon) {
		this.startCardMon = startCardMon;
	}
	public int getEndCardMon() {
		return endCardMon;
	}
	public void setEndCardMon(int endCardMon) {
		this.endCardMon = endCardMon;
	}
	public int getServiceMon() {
		return serviceMon;
	}
	public void setServiceMon(int serviceMon) {
		this.serviceMon = serviceMon;
	}
	public int getIsPay() {
		return isPay;
	}
	public void setIsPay(int isPay) {
		this.isPay = isPay;
	}
	

}
